import 'package:flutter/material.dart';
import 'package:flutter_demo/widget/buttons.dart';
import 'package:flutter_demo/widget/choose_file.dart';

class UploadConsistentScreen extends StatelessWidget {

  final GlobalKey _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {

    var et_pid = Padding(
      padding: const EdgeInsets.fromLTRB(64, 32, 64, 32),
      child: Container(
        padding: const EdgeInsets.symmetric(horizontal: 16),
        child: TextFormField(
          autofocus: true,
          decoration: const InputDecoration(
            labelText: '法定代表人身份证号',
            hintText: '您的法定代表人身份证号',
            border: InputBorder.none,
          ),
          validator: (value) {
            if (value!.trim().isEmpty) {
              return '用户名不能为空';
            } else if (value.trim().length > 19) {
              return '用户名超出最大长度';
            } else {
              return null;
            }
          },
        ),
        decoration: BoxDecoration(
          border: Border.all(color: Colors.black26, width: 1.0),
          borderRadius: BorderRadius.circular(5.0),
        ),
      ),
    );

    var chooseConsistent = Container(
      alignment: Alignment.center,
      child: ChoosePictureView(),
    );

    return Scaffold(
      appBar: AppBar(
        title: const Text('上传与原件相符章'),
      ),
      body: Form(
        key: _formKey,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            et_pid,
            Container(
              margin: EdgeInsets.fromLTRB(64, 0, 64, 32),
              child: Row(
                children: [
                  Expanded(child: chooseConsistent),
                  Expanded(
                    child: BaseButton(
                      radius: 12,
                      width: 180,
                      onTap: () {
                        if ((_formKey.currentState as FormState).validate()) {
                          // 验证通过提交数据
                        }
                      },
                      child: Text(
                        '完成',
                        style: TextStyle(
                          fontSize: 16,
                          color: Colors.white,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}